<?php
    include 'include/function.php';
    valid_user();
	include 'include/header.php';
    $user_info = get_user_info($_SESSION['user_id']);
?>
<title>Profile</title>
    <div id="headline">
        <div class="wrapper">
            <h2>Profile</h2>
        </div>
    </div>    

<div id="pagebody">
	<div class="wrapper">
        <div class="notice">
            Please leave "New Passord" and "Retype" blank if you do not want to modify your password.
        </div>
    <form action="profile.do" method="post" onsubmit="encode()">
    <table class="center" id="register"><tbody>
        <tr>
            <td><strong>User ID:&nbsp;</strong></td>
            <td><input class="text" name="user_id" type="text" value="<?php echo $user_info['user_id']; ?>" size="20" /></td>
        </tr>
        <tr>
            <td><strong>Password:&nbsp;</strong></td>
            <td><input class="text" size="20" type="password" id="ps0" name="old_password" value="" /></td>
        </tr>
        <tr>
            <td><strong>New Password:&nbsp;</strong></td>
            <td><input class="text" size="20" type="password" id="ps1" name="new_password" /></td>
        </tr>
        <tr>
            <td><strong>Retype:&nbsp;</strong></td>
            <td><input class="text" size="20" type="password" id="ps2" name="repeatpassword" /></td>
        </tr>
        <tr>
            <td><strong>Nick Name:&nbsp;</strong></td>
            <td><input class="text" size="20" type="text" name="nick" value="<?php echo $user_info['nickname']; ?>" /></td>
        </tr>
        <tr>
            <td><strong>Email:&nbsp;</strong></td>
            <td><input class="text" size="20" type="text" name="email" value="<?php echo $user_info['email']; ?>" /></td>
        </tr>
        <tr>
            <td><strong>School:&nbsp;</strong></td>
            <td><input class="text" size="20" type="text" name="school" value="<?php echo $user_info['school']; ?>"/></td>
        </tr>
        <tr>
            <td colspan=2>
                <input class="button-secondary" type="submit" value="Submit" name="submit" />&nbsp;
                <input class="button-secondary" type="reset" value="Reset" name="reset" />
            </td>
        </tr>
    </tbody></table>
    </form>
    <br /><br />
    </div>
</div>
<script src="common/md5.js"></script>
<script language="javascript">
function encode() {
    var ps1 = document.getElementById('ps0');
    ps1.value = MD5(ps1.value);
    var ps1 = document.getElementById('ps1');
    ps1.value = MD5(ps1.value);
    var ps2 = document.getElementById('ps2');
    ps2.value = MD5(ps2.value);
	return true;
}
</script>

<?php
	include('include/footer.php');
?>


